<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <h1>{{message}}</h1>
        <button @click="btnclick">按钮1</button>

        <button @click="but2click('ran',age)">按钮2</button>
        <!-- 在模板中明确获得event对象 -->
        <button @click="but3click('ran',age,$event)">按钮3</button>

    </div>
    <script src="https://unpkg.com/vue@next"></script>
    <script>
        //用vue创建app
        const app=Vue.createApp({
            data:function(){
                return{
                    message:"Hello world",
                    age:19
                }
            },
            methods:{
                // 1.默认参数
                btnclick(event){
                    console.log("btnclick",event);
                },
                //2.明确参数
                but2click(name,age){
                    console.log("but2click:",name,age);
                },
                //3.默认加明确
                but3click(name,age,event){
                   console.log("but3click:",name,age,event);
                }
            }
        })
        //挂载app
        app.mount("#app")
    </script>

</body>
</html>